package api

import (
	"cec-server/app/common/resp"
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

type User struct{}

func (u User) Hello(context *gin.Context) {
	context.String(http.StatusOK, "hello ,huibenguan")
}

func (u User) List(ctx *gin.Context) {
	id := ctx.Param("id")
	fmt.Println(ctx.Param("name"))
	ctx.JSON(http.StatusOK, id)
}

type search struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

func (u User) Insert(ctx *gin.Context) {
	//id := ctx.Param("id")
	//fmt.Println(ctx.Param("name"))

	search := &search{}
	//userTemp := make(map[string]interface{})
	err := ctx.BindJSON(&search)
	if err == nil {
		resp.ReutrnSuccess(ctx, 200, "haha", search, 1)
	}

	//ctx.JSON(http.StatusOK, id)
}

func (u User) Add(ctx *gin.Context) {
	ctx.JSON(http.StatusOK, "user add")
}

func (u User) Delete(ctx *gin.Context) {
	ctx.JSON(http.StatusOK, "user delete")
}
